<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>new操作符</title>
  </head>

  <body></body>
  <script>
    // 手写new
    function mynew(fn, ...args){
      let obj = {};
      obj.__proto__ = fn.prototype;
      let result = fn.call(obj, ...args);
      return result instanceof Object? result: obj;
    }
  </script>
</html>
